import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
//登录页面
const login = r => require.ensure([], () => r(require('@/components/common/login')), 'login');
//菜单栏
const manage = r => require.ensure([], () => r(require('@/components/common/manage')), 'manage');
//首页
const home = r => require.ensure([], () => r(require('@/components/common/home')), 'home');
//后台用户
const adminUser = r => require.ensure([], () => r(require('@/components/page/user/adminUser')), 'adminUser');
//前台用户
const frontUser = r => require.ensure([], () => r(require('@/components/page/user/frontUser')), 'frontUser');
//商品管理
const productIndex = r => require.ensure([], () => r(require('@/components/page/product/index')), 'productIndex');
//订单管理
const ordersIndex = r => require.ensure([], () => r(require('@/components/page/orders/index')), 'ordersIndex');

const routes = [
	{
		path: '/',
		component: login
	},
	{
		path: '/manage',
		component: manage,
		name: '',
		children: [
            {
                path: '',
                component: home,
                meta: []
            },
            {
                path: '/adminUser',
                component: adminUser,
                meta: ['用户管理', '后台用户'],
            },{
                path: '/frontUser',
                component: frontUser,
                meta: ['用户管理', '前台用户'],
            },{
                path: '/productIndex',
                component: productIndex,
                meta: ['商品管理', '商品管理'],
            },{
                path: '/ordersIndex',
                component: ordersIndex,
                meta: ['订单管理', '订单管理'],
            },

		]
	}
]

export default new Router({
	routes,
	strict: process.env.NODE_ENV !== 'production',
})
